function checkAll(e){
	var flag=$(e).prop("checked");
	if(init.chooseType=="one"){
		layer.msg("只能选择一个组货，不能多选！");
		return false;
	}
	if(flag){
		$(".goods-checkbox").prop("checked",true);
	}else{
		$(".goods-checkbox").prop("checked",false);
	}
}
function checkOne(e){
	var flag=$(e).prop("checked");
	if(init.chooseType=="one" && flag){
		$(".goods-checkbox").prop("checked",false);
		$(e).prop("checked",true);
	}
}
$(function(){
	$("#search-button").click(function(){
		var keyword=$("input[name='keyword']").val();
		var style=$("select[name='style']").val();
		var scene =$("select[name='scene']").val();
			
		var url=basePath+"/group/queryGroupList.shtml?pageNo="+1+"&keyword="+keyword
		+"&scene=" +scene + "&style="+style+"&chooseType="+init.chooseType;
		window.location.href=url;
	})
	$("#save-button").click(function(){
		var goodsChecked=$(".goods-checkbox:checked");
		var chooseType=init.chooseType;
		if(goodsChecked.length==0){
			layer.msg("请选择组货！");
			return false;
		}
		var goodsArray=new Array();
		if(chooseType == 'one'){
			var groupId=$(goodsChecked[0]).val();
			var scene=$(goodsChecked[0]).attr("data-scene");
			var coverImage=$(goodsChecked[0]).attr("data-image");
			var style=$(goodsChecked[0]).attr("data-style");
			var customer=$(goodsChecked[0]).attr("data-customer");
			var goods={
					"id":groupId,
					"coverImage":coverImage,
					"style":style,
					"scene":scene,
					"customer":customer
			}
			goodsArray.push(goods);
		}else{
			for(i=0;i<goodsChecked.length;i++){
				var groupId=$(goodsChecked[i]).val();
				var scene=$(goodsChecked[i]).attr("data-scene");
				var coverImage=$(goodsChecked[i]).attr("data-image");
				var style=$(goodsChecked[i]).attr("data-style");
				var customer=$(goodsChecked[i]).attr("data-customer");
				var goods={
						"id":groupId,
						"coverImage":coverImage,
						"style":style,
						"scene":scene,
						"customer":customer
				}
				goodsArray.push(goods);
			}
		}
		parent.closeGroupLayer(1,goodsArray);
	})
})

function fanye(pageNo){
	var keyword=init.keyword;
	var style=init.style;
	var scene =init.scene;
		
	var url=basePath+"/group/queryGroupList.shtml?pageNo="+1+"&keyword="+keyword
	+"&scene=" +scene + "&style="+style+"&chooseType="+init.chooseType;
	window.location.href=url;
}